<template>
	<a-spin :spinning="loading">
		<a-card>
			<section slot="title">积分设置</section>
			<a-form :form="form">
				<div>基础设置：</div>
				<a-form-item class="mb-15" label="积分抵扣最大值" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'pointTradeDeductMaxPrice',
              {
                rules: [{  message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
					</div>
				</a-form-item>
				<a-form-item class="mb-15" label="多少积分" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'pointTradeDeductUnitPrice',
              {
                rules: [{  message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">抵1元；</span>
					</div>
				</a-form-item>
				<div>商城/服务：</div>
				<a-form-item class="mb-15" label="购买普通商品" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'normalOrderGivePoint',
              {
                rules: [{  message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">元获取一积分；</span>
					</div>
				</a-form-item>
				<a-form-item class="mb-15" label="购买秒杀商品" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'seckillOrderGivePoint',
              {
                rules: [{  message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">元获取一积分；</span>
					</div>
				</a-form-item>
				<a-form-item class="mb-15" label="购买团购商品" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'combinationOrderGivePoint',
              {
                rules: [{  message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">元获取一积分；</span>
					</div>
				</a-form-item>
				<a-form-item class="mb-15" label="购买砍价商品" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'barginOrderGivePoint',
              {
                rules: [{  message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">元获取一积分；</span>
					</div>
				</a-form-item>
				<a-form-item class="mb-15" label="购买新人专享商品" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'newCustomerGivePoint',
              {
                rules: [{  message: '请输入', whitespace: true ,type:'any'}]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">元获取一积分；</span>
					</div>
				</a-form-item>
				<a-form-item class="mb-15" label="购买老用户专享商品" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'existedCustomerGivePoint',
              {
                rules: [{  message: '请输入', whitespace: true ,type:'any'}]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">元获取一积分；</span>
					</div>
				</a-form-item>
				<a-form-item class="mb-15" label="购买服务" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'serverOrderGivePoint',
              {
                rules: [{  message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">元获取一积分；</span>
					</div>
				</a-form-item>
				<a-form-item class="mb-15" label="分享商品：获得" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'shareProductGivePoint',
              {
                rules: [{  message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">积分；</span>
					</div>
				</a-form-item>
				<a-form-item class="mb-15" label="收藏商品：获得" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'followProductGivePoint',
              {
                rules: [{  message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">元获取一积分；</span>
					</div>
				</a-form-item>
				<a-form-item class="mb-15" label="收藏店铺：获得" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'followStoreGivePoint',
              {
                rules: [{  message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">元获取一积分；</span>
					</div>
				</a-form-item>
				<a-form-item class="mb-15" label=" 拉新获得" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'inviteMemberGivePoint',
              {
                rules: [{  message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">元获取一积分；</span>
					</div>
				</a-form-item>
				<div>宠友圈：</div>
				<a-form-item class="mb-15" label=" 发布动态：获得" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'publishContentGivePoint',
              {
                rules: [{  message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">积分；</span>
					</div>
				</a-form-item>
				<a-form-item class="mb-15" label=" 点赞：获得" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'likeContentGivePoint',
              {
                rules: [{  message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">积分；</span>
					</div>
				</a-form-item>
				<a-form-item class="mb-15" label="关注：获得" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'followContentGivePoint',
              {
                rules: [{  message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">积分；</span>
					</div>
				</a-form-item>
				<!--        <div>用户消费：</div>-->
				<!--        <a-form-item class="mb-15" label="" :label-col="labelCol" :wrapper-col="wrapperCol">-->
				<!--          <div class="flex">-->
				<!--            <a-input-->
				<!--            placeholder="请输入"-->
				<!--            v-decorator="[-->
				<!--              'pointByConsumptionTerm',-->
				<!--              {-->
				<!--                rules: [{  message: '请输入', whitespace: true }]-->
				<!--              }-->
				<!--            ]"-->
				<!--            maxLength="30"-->
				<!--            class="input"-->
				<!--          ></a-input>-->
				<!--          <span class="ml-10">积分抵扣一元；</span>-->
				<!--          </div>-->
				<!--        </a-form-item>-->
				<div>积分有效期：</div>
				<a-form-item class="mb-15" label="消费获取积分有效期：" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'pointByConsumptionTerm',
              {
                rules: [{  message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">月；</span>
					</div>
				</a-form-item>
				<a-form-item class="mb-15" label="其他获取积分有效期：" :label-col="labelCol" :wrapper-col="wrapperCol">
					<div class="flex">
						<a-input placeholder="请输入" v-decorator="[
              'pointByOtherWayTerm',
              {
                rules: [{message: '请输入', whitespace: true,type:'any' }]
              }
            ]" maxLength="30" class="input"></a-input>
						<span class="ml-10">月；</span>
					</div>
				</a-form-item>
				<a-button @click="confirmOk" class="mx-8" type="primary">保存</a-button>
			</a-form>
		</a-card>
	</a-spin>
</template>
<script>
	import {
		scoreSave,
		scoreGet
	} from "@/api/newPet";

	export default {
		data() {
			return {
				form: this.$form.createForm(this),
				loading: false,
				labelCol: {
					span: 3
				},
				wrapperCol: {
					span: 16
				}
			}
		},
		computed: {},
		watch: {},
		created() {
			this.getData()
		},
		methods: {
			confirmOk() {
				this.form.validateFields((err, values) => {
					if (!err) {
						const {
							info
						} = this
						let data = {
							...this.$utils.trimValue(values),
						}

						scoreSave(data)
							.then(() => {
								this.$message.success('修改成功！')
								this.getData()
							})
							.finally(() => {
								this.loading = false
							})
					}
					// this.loading = true

				})
			},
			getData() {
				scoreGet().then((res) => {

					this.form.setFieldsValue({
						...res
					})

				})
			}
		}
	}
</script>
<style lang="less" scoped>
	.flex {
		display: flex;
	}

	.input {
		width: 200px;
	}
</style>